#!/bin/sh
# Default settings
setup_color() {
	# Only use colors if connected to a terminal
	if [ -t 1 ]; then
		RED=$(printf '\033[31m')
		GREEN=$(printf '\033[32m')
		YELLOW=$(printf '\033[33m')
		BLUE=$(printf '\033[34m')
		BOLD=$(printf '\033[1m')
		RESET=$(printf '\033[m')
	else
		RED=""
		GREEN=""
		YELLOW=""
		BLUE=""
		BOLD=""
		RESET=""
	fi
}

get_wrapper_path(){
    old_wrapper_path="/usr/local/bin/virtualenvwrapper.sh"
    new_wrapper_path="${HOME}/.local/bin/virtualenvwrapper.sh"
    if [ -f ${old_wrapper_path} ];then
        echo ${old_wrapper_path}
    else
        echo ${new_wrapper_path}
    fi
}

get_shell(){
    if [[ ${SHELL} == *'zsh'* ]];then
        echo ".zshrc"
    else
        echo ".bashrc"
    fi
}


VIRTUALENVWRAPPER_PYTHON=$(which python3)
WORK_HOME="${HOME}/.virtualenvs"
WRAPPER_PATH=$(get_wrapper_path)
SHELL=$(get_shell)
BASH_FILE="${HOME}/${SHELL}"

show_commands(){
    echo "-----------------------"
    echo "mkenv: make a new virtual environment"
    echo "rmenv: remove a virtual environment"
    echo "workon: activate a virtual environment"
    echo "workout: deactivate from current virtual environment"
}
main() {
#    echo "${BLUE}installing virtualenv${RESET}"
#    pip3 install virtualenv
#    echo "${BLUE}installing virtualenvwrapper${RESET}"
#    pip3 install virtualenvwrapper
#    echo "${BLUE}write config to ${BASH_FILE}${RESET}"
#    echo "export VIRTUALENVWRAPPER_PYTHON=${VIRTUALENVWRAPPER_PYTHON}
#export WORKON_HOME=${WORK_HOME}
#source ${WRAPPER_PATH}
#alias workout='deactivate'
#alias mkenv='mkvirtualenv'
#alias rmenv='rmvirtualenv'" >> ${BASH_FILE}
#source ${BASH_FILE}
#echo "${RED}python virtual environment build success${RESET}"
#show_commands
get_shell
}

setup_color
main